#include <glib.h>

int main (int argc, char** argv)
{
    GRegex* regex;
    GMatchInfo *match_info;
    GError *error = NULL;
    const gchar *str = "abcd1234efgh567xyz";
    const gchar *pat = "[0-9]+";

    regex = g_regex_new(pat, 0, 0, &error);

    g_regex_match_full(regex, str, -1, 5, 0, &match_info, &error);

    while (g_match_info_matches(match_info)) {
        gchar* word = g_match_info_fetch(match_info, 0);
        g_print("%s in %s \n",word, str);
        g_free(word);

        g_match_info_next(match_info, NULL);
    }

    g_match_info_free(match_info);
    g_regex_unref(regex);

  return 0;
}